<?php
require('smarty/Smarty.class.php');

class Controller{
	protected $smarty;
	protected $loader;

	public function index(){}
	
	public function __construct($loader){
		$this->smarty = new Smarty();
		$this->smarty->template_dir = 'view';
		$this->smarty->compile_dir = 'core/smarty/template_c';
		$this->smarty->cache_dir = 'core/smarty/cache';
		$this->smarty->config_dir = 'core/smarty/configs';
		$this->loader = $loader;
		
	}
	
	public function postExecute($action_name){
		$e = get_class($this);
		$dir = strtolower(substr($e, 0, strpos($e, 'Controller')));
		$this->smarty->assign('content', $dir.'/'.$action_name);
		if(!empty($_SESSION)){
		$this->smarty->assign('username', $_SESSION['username']);
		$this->smarty->assign('user_id', $_SESSION['user_id']);
                $this->smarty->assign('is_teacher', $_SESSION['is_teacher']);
		$this->smarty->assign('title', "Kémia éve");
		}
		$this->smarty->display('layout.tpl');
	}
}